﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Cn.Edwon.Web.Support;
using Cn.Edwon.Biz;
using System.Reflection;
using Cn.Edwon.Spring;
using Cn.Cellula.Model;
using Cn.Cellula.Model.Content;

namespace Cn.Cellula.Website.Admin.Content.GuestBook {
    public partial class Reply : PageSupport {
        IBiz biz = BizFactory.Get<IBiz>();
        String EOKey = null;
        protected void Page_Load(object sender, EventArgs e) {
            EOKey = Request.QueryString["id"];
            if (!Page.IsPostBack) {
                FillForm(EOKey);
            }
        }

        private void FillForm(String rKey) {
            VGuestbookEO eo = biz.Load<VGuestbookEO>(rKey);
            this.lab_Content.Text = eo.Content;
            this.lab_LastDate.Text = Convert.ToDateTime(eo.LastDate).ToString("yyyy-MM-dd HH:mm:ss");
            this.lab_Poster.Text = eo.Poster;
            this.lab_PosterEmail.Text = eo.PosterEmail;
            this.lab_PosterTel.Text = eo.PosterTel;
            this.mtxt_Reply.Text = eo.Reply;
            this.lab_TypeName.Text = eo.TypeName;
        }

        protected void btn_Reply_Click(object sender, EventArgs e) {
            TGuestbookEO eo = biz.Load<TGuestbookEO>(EOKey);
            eo.Reply = this.mtxt_Reply.Text;
            eo.ReplyDate = DateTime.Now;
            eo.Replyer = (this.Actor != null) ? this.Actor.UserName : "unknown";
            eo.IsVerified = 1;
            biz.Update<TGuestbookEO>(eo);
            Response.Redirect("List.aspx");
        }
    }
}
